const readline = require('readline');
const fs = require('fs');
var file = fs.createReadStream(logFile);

var rl = readline.createInterface({
  input: file,
  output: process.stdout,
  terminal: false
});

var counter = {};
rl.on('line',function(line){
  var items = line.split(' ');
  if(items.length >= 2){
    console.log("%s",items[1].substring(0,8));
    var timestr = items[1].substring(0,8);
    if(counter.hasOwnProperty(timestr)){
      counter[timestr]++;
    }else{
      counter[timestr] = 1;
    }
  }
});

rl.on('close',function(){
  rl.close();
  file.close();
  
  var keys = Object.keys(counter);

  var arr = [];  
  for(var index in keys){
    var key = keys[index];    
    arr.push({count:counter[key],key:key});
  }
  
  ///sort by count descent
  arr.sort(function(item1,item2){
    return item2.count - item1.count;
  });
  
  for(var index in arr){
    console.log('%s %d',arr[index].key,arr[index].count);
  }
  
});